package com.my.oauth.clien.controller;

import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("getCurrenUser")
    public Object getAuth(Authentication authentication, HttpServletRequest request){
        //jwt方式的解析
//        String authorization = request.getHeader("Authorization");
//        String token = authorization.substring(authorization.indexOf("bearer") + 7);
//        Claims body = Jwts.parser().setSigningKey("key".getBytes(StandardCharsets.UTF_8)).parseClaimsJws(token)
//                .getBody();
//        return body;
        return authentication;
        //redis方式直接获取
//        return authentication.getPrincipal();
    }
}
